'use strict';

export default class extends think.model.base {

  async addUser(usrData){
    usrData.usr_reg_dt = think.datetime(new Date(), 'YYYY-MM-DD HH:mm:ss');
    return await this.model('user').thenAdd(usrData, {usr_name: usrData.usr_name});
  }

  async findUser(usrId){
    return await this.model('user').where({usr_id: usrId}).find();
  }

  async updateUser(usrData){
    let usrId = usrData.usr_id;
    delete usrData.usr_id;
    return await this.model('user').where({usr_id: usrId}).update(usrData);
  }

  async loginUser(usrData){
    return await this.model('user').where({usr_name: usrData.usr_name, usr_pwd: usrData.usr_pwd}).find();
  }

  async addUserGameInfo(ugiData){
    return await this.model('user_game_info').thenAdd(ugiData, {ugi_id: ugiData.ugi_id});
  }
}